tiproxy: add annotation tiproxy-graceful-shutdown-delete-delay-seconds to remove label before deleting pods#6829
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
1b9bd2d to
de28487
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #6829 +/- ##
==========================================
- Coverage 37.16% 36.50% -0.66%
==========================================
Files 390 392 +2
Lines 22360 27264 +4904
==========================================
+ Hits 8310 9954 +1644
- Misses 14050 17310 +3260
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
| } | ||
| } | ||
|
|
||
| res, _ := task.RunTask(ctx, common.TaskInstanceFinalizerDel[scope.TiProxy](state, c, tiproxyFinalizerSubresourceLister)) |
There was a problem hiding this comment.
Add a new task and do not run another task in this task. If task is not fail, next task will be run.
| return task.NameTaskFunc("FinalizerDel", func(ctx context.Context) task.Result { | ||
| tiproxy := state.Object() | ||
|
|
||
| pod, err := apicall.GetPod[scope.TiProxy](ctx, c, tiproxy) |
There was a problem hiding this comment.
move common.TaskContextPod[scope.TiProxy](state, r.Client) before this task and no need to get pod again.
| }) | ||
| } | ||
|
|
||
| func drainOrDeletePod(ctx context.Context, c client.Client, tiproxy *v1alpha1.TiProxy, pod *corev1.Pod) (time.Duration, error) { |
There was a problem hiding this comment.
How to notify the tiproxy that it is terminating?
de28487 to
d837373
Compare
Background
I'm designing the graceful restarting of TiProxy in cloud environment. The expected process is just to:
maxSurge.terminationGracePeriodSeconds(e.g. 24h).However, we cannot modify the
terminationGracePeriodSecondswithout restarting pods. To be able to restart the existing pods gracefully, we'd better to design another workaround for it.Design
core.pingcap.com/tiproxy-graceful-shutdown-delete-delay-seconds. With this annotation, the deletion ofTiProxyobject will have two extra steps before removing the pod: remove the label, wait for several seconds.TiProxyGrouptoTiProxywithout rolling restart, so we can modify it for existing resources.I understand it's not elegant (so I didn't use a
specfield to describe it) as it doesn't know when theTiProxyactually has no connection and can exit earlier. IMO, it'd be still better to use a biggerterminationGracePeriodSecondsto gracefully shutdown.Usage
Patch an existing
TiProxyGroup, so it'll wait for a while before deleting the pods: